import { PagedRequestDto } from "@shared/component-base";

export interface IDepartmentDto {
  departmentName: string;
  code: string;
  id: number;
  parentId: number;
  parentDepartmentName: string;
  summary: string;
  taxis: number;
}

export class DepartmentDto implements IDepartmentDto {
  departmentName: string;
  code: string;
  id: number;
  parentId: number;
  parentDepartmentName: string;
  summary: string;
  taxis: number;

  constructor(data?: IDepartmentDto) {
    if (data) {
      for (var property in data) {
        if (data.hasOwnProperty(property))
          (<any>this)[property] = (<any>data)[property];
      }
    }
  }

  init(data?: any) {
    if (data) {
      this.id = data["id"];
      this.departmentName = data["departmentName"];
      this.code = data["code"];
      this.parentId = data["parentId"];
      this.parentDepartmentName = data["parentDepartmentName"];
      this.summary = data["summary"];
      this.taxis = data["taxis"];

    }
  }

  static fromJS(data: any): DepartmentDto {
    data = typeof data === 'object' ? data : {};
    let result = new DepartmentDto();
    result.init(data);
    return result;
  }

  toJSON(data?: any) {
    data = typeof data === 'object' ? data : {};
    data["id"] = this.id;
    data["departmentName"] = this.departmentName;
    data["code"] = this.code;
    data["parentId"] = this.parentId;
    data["parentDepartmentName"] = this.parentDepartmentName;
    data["summary"] = this.summary;
    data["taxis"] = this.taxis;

    return data;
  }

  clone() {
    const json = this.toJSON();
    let result = new DepartmentDto();
    result.init(json);
    return result;
  }
}

export class DepartmentListQueryDto extends PagedRequestDto {
  phone: string;
  keywords: string;

  init(data?: any) {
    if (data) {
      this.pageIndex = data["pageIndex"];
      this.pageSize = data["pageSize"];
      this.sortField = data["sortField"];
      this.sortOrder = data["sortOrder"];
      this.keywords = data["keywords"];
    }
  }

  toJSON(data?: any) {
    data = typeof data === 'object' ? data : {};
    data["pageIndex"] = this.pageIndex;
    data["pageSize"] = this.pageSize;
    data["sortField"] = this.sortField;
    data["sortOrder"] = this.sortOrder;
    data["keywords"] = this.keywords;
    return data;
  }
}

export interface IDepartmentEditDto {
  departmentName: string;
  id: number;
  code: string;
  parentId: number;
  summary: string;
  taxis: number;
}

export class DepartmentEditDto implements IDepartmentEditDto {
  id: number;
  departmentName: string;
  code: string;
  parentId: number;
  summary: string;
  taxis: number;

  constructor(data?: IDepartmentEditDto) {
    if (data) {
      for (var property in data) {
        if (data.hasOwnProperty(property))
          (<any>this)[property] = (<any>data)[property];
      }
    }
  }

  init(data?: any) {
    if (data) {
      this.departmentName = data["departmentName"];
      this.code = data["code"];
      this.parentId = data["parentId"] != null ? data["parentId"].toString() : "";
      this.id = data["id"];
      this.summary = data["summary"];
      this.taxis = data["taxis"];

    }
  }

  static fromJS(data: any): DepartmentEditDto {
    data = typeof data === 'object' ? data : {};
    let result = new DepartmentEditDto();
    result.init(data);
    return result;
  }

  toJSON(data?: any) {
    data = typeof data === 'object' ? data : {};
    data["departmentName"] = this.departmentName;
    data["code"] = this.code;
    data["id"] = this.id;
    data["parentId"] = this.parentId;
    data["summary"] = this.summary;
    data["taxis"] = this.taxis;

    return data;
  }

  clone() {
    const json = this.toJSON();
    let result = new DepartmentEditDto();
    result.init(json);
    return result;
  }
}


